package com.zlcx.tz.live.repository;

import com.zlcx.tz.live.domain.TimeLearnRoomUsersDO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @author anjl
 */
@Repository
public interface TimeLearnRoomUsersRepository extends JpaRepository<TimeLearnRoomUsersDO, Long>, JpaSpecificationExecutor<TimeLearnRoomUsersDO> {

    TimeLearnRoomUsersDO findByUserId(Long userId);

    @Modifying
    @Query(value = "delete from tz_time_learn_room_users where id = ?1 ", nativeQuery = true)
    void deleteById(Long id);

    Page<TimeLearnRoomUsersDO> findByRoomId(Long roomId, Pageable page);
}
